package com.andyzhou.astatine;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView title = (TextView) findViewById(R.id.mainTitle);
        title.setText("Astatine");
        Button btn = (Button) findViewById(R.id.button);
        btn.setOnClickListener((View.OnClickListener) v -> {
            ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            EditText editText = (EditText) findViewById(R.id.editTextTextPersonName);
            String input = editText.getText().toString();
            Translate t = new Translate();
            Toast.makeText(getApplicationContext(),t.translate(input), Toast.LENGTH_SHORT).show();
        });
    }
}
